package com.lianqi.emcpframework.extend.script;

import com.lianqi.emcpframework.extend.script.engine.JavaScriptEngine;
import com.lianqi.emcpframework.extend.script.engine.SpElEngine;

import java.util.HashMap;
import java.util.Map;

/**
 * @program emcp-framework
 * @ClassName DynamicScriptEngineFactory
 * @description: 动态脚本引擎工厂类
 * @author: sky
 * @create: 2018/12/04 19:46
 */
public class DynamicScriptEngineFactory {

    private static final Map<String,DynamicScriptEngine> map = new HashMap<>();
    static {
        JavaScriptEngine javaScriptEngine = new JavaScriptEngine();
        map.put("js",javaScriptEngine);
        map.put("javascript",javaScriptEngine);
        try {
            Class.forName("org.springframework.expression.ExpressionParser");
            map.put("spEL",new SpElEngine());
        }catch (ClassNotFoundException e){

        }
    }

    public static final DynamicScriptEngine getEngine(String type){
        return map.get(type);
    }

}
